<template>
	<view class="bg-light flex flex-column">
		<radio-group>
			<view style="position: relative" @click.stop="handle(index)" class="mx-3 mt-3 p-3 bg-white rounded-lg"
				v-for="(item, index) in Address" :key="index">
				<view class="border-bottom border-light">
					<text class="font font-weight-bold" style="display: block">{{
            item.Warehouse_Address
          }}</text>
					<text class="font py-2"
						style="display: block">{{ item.Warehouse_Name }}&nbsp;{{ item.Operation_ID }}</text>
				</view>
			</view>
		</radio-group>
		<!-- <view class="font-sm py-2 text-center">
      <text>{{ DropdownRow_Status }}</text>
    </view> -->
		<view :style="'height:' + fixedHeight + 'px'"> </view>
		<view id="fixed" class="px-4 py-2 fixed-bottom bg-white flex">
			<!-- <view
        class="w-100 bg-info rounded text-center py-2 mr-2 text-white font-md"
        @click="Add()"
        hover-class="bg-hover-info"
        :hover-stay-time="150"
        >新增地址</view
      >
      <view
        class="w-100 rounded text-center py-2 text-white font-md"
        :class="buttonType"
        @click="SelectDelete"
        >{{ buttonText }}</view
      > -->
		</view>
	</view>
</template>

<script>
	const app = getApp();
	import {
		getWaresList
	} from '@/api/merchant.js';
	export default {
		data() {
			return {
				isdelete: false,
				onReach: true,
				fixedHeight: 0,
				Address: [], //地址列表
				Path: null, //回调路径
				loading: true,
				buttonText: "删除地址",
				buttonType: "bg-danger",
				DropdownRow_Status: "下拉查看更多",
				total: 0,
				Domain_ICON: app.globalData.Domain_ICON, //全局变量域名
				memberInfo: app.globalData.memberInfo,
			};
		},
		onShow() {
			this.getWares();
		},
		onLoad(options) {
			this.fixed();
		},
		methods: {
			fixed() {
				//底部模块高度获取
				const query = uni.createSelectorQuery();
				query
					.select("#fixed")
					.boundingClientRect((data) => {
						this.fixedHeight = data.height;
					})
					.exec();
			},
			async getWares() {
				uni.showLoading({
					title: "查询中",
				});
				this.DropdownRow_Status = "玩命加载中...";
				//获取所有可选仓库
				const res = await getWaresList({
					Data: "warehouse_info",
					Enterprise_Info_SerialNumber: app.globalData.memberInfo.Enterprise_Info_SerialNumber
				});
				this.Address = res;
				uni.hideLoading();
			},

			handle(index) {
				console.log(this.memberInfo);
				//点击地址
				uni.setStorageSync("warehouse_address", {
					Dealer_Authority: this.memberInfo.Dealer_Authority,
					Warehouse_Address: this.Address[index],
				});
				uni.navigateBack();
			},
		},
		onReachBottom() {
			if (this.onReach) {
				if (this.Address.length < this.total) {
					this.form.page++;
					this.getList(this.form, true);
				} else {
					this.onReach = false;
					this.DropdownRow_Status = "没有更多了";
				}
			}
		},
	};
</script>

<style scoped>
	page {
		background-color: #f8f9fa;
	}
</style>